//
//  GifVC.m
//  doubleEduStudents
//
//  Created by 盛洋 on 2021/1/19.
//  Copyright © 2021 shengYang. All rights reserved.
//

#import "GifVC.h"

@interface GifVC ()
@property (strong, nonatomic) IBOutlet UIImageView *star_img1;
@property (strong, nonatomic) IBOutlet UIImageView *star_img2;
@property (strong, nonatomic) IBOutlet UIImageView *feidie_view;
@end

@implementation GifVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleView.backgroundColor = self.titleView.separatorLineView.backgroundColor = [UIColor colorWithHexString:@"0B0F2C"];
    [self.titleView.backBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    
    //动画内容
    [self showStar1];
    [self showStar2];
    [self showLogView];

}

-(void)showStar1{
    // 1,创建动画
    CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    // 设置CALayer要修改的属性
    NSValue *v1 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_W , SCREEN_H * 0.01)];
    NSValue *v2 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_W * 0.01, SCREEN_H)];
    
    // 设置position属性的每一帧要改变的值
    anim.values = @[v1,v2];
    
    //重复次数 默认1
    //        anim.repeatCount = 1;
    //设置动画时间，时间内动画一直重复
    anim.repeatDuration = 60;
    //是否原路返回 默认NO
    anim.autoreverses = NO;
    //移动速度，越小越快
    anim.duration = 2.0f;
    
    // 3,添加动画
    [self.star_img1.layer addAnimation:anim forKey:nil];
}

-(void)showStar2{
    // 1,创建动画
    CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    // 设置CALayer要修改的属性
    NSValue *v1 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_W -100 , SCREEN_H * 0.01)];
    NSValue *v2 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_W * 0.1, SCREEN_H)];
    // 设置position属性的每一帧要改变的值
    anim.values = @[v1,v2];
    
    //重复次数 默认1
    //        anim.repeatCount = 1;
    //设置动画时间，时间内动画一直重复
    anim.repeatDuration = 60;
    //是否原路返回 默认NO
    anim.autoreverses = NO;
    //移动速度，越小越快
    anim.duration = 3.0f;
    
    // 3,添加动画
    [self.star_img2.layer addAnimation:anim forKey:nil];
}


-(void)showLogView{
    
//    CABasicAnimation *rotationAnimation;
//     rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
//     rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI*2.0];
//     rotationAnimation.duration = 1;
//     rotationAnimation.repeatCount = HUGE_VALF;
//    [self.feidie_view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
    UIImage *image1 = [UIImage imageNamed:@"加载1"];
    UIImage *image2 = [UIImage imageNamed:@"加载2"];
    UIImage *image3 = [UIImage imageNamed:@"加载3"];
    NSArray *imagesArray = @[image1,image2,image3];
    
    self.feidie_view.animationImages = imagesArray;
    self.feidie_view.animationDuration = .5;
    //循环次数
    self.feidie_view.animationRepeatCount = 0;
    [self.feidie_view startAnimating];
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
